<?php htmlTemplate('admin_header_frame.php');?>
<div class="title">设置用户
<?php if ($user['isadmin']!=3){?>
<a  href="<?php echo ZSM_WWW_HOST.'admin.php/admin/home/user/'?>" class="title_button">用户列表</a>
<?php }?>
</div>
<script type="text/javascript">
function checkForm(){	
	var username = $.trim($("#username").val());	
	var password = $.trim($("#password").val());
	var isadmin = $.trim($("#isadmin").val());
	if(isadmin!=1){
		var plantform_id = $.trim($("#plantform_id").val());
	}else{
		plantform_id = 0;
	}
	var email  = $.trim($("#email ").val());
	var tel  = $.trim($("#tel ").val());
	
	if (username==''){	
		parent.showAlert('用户名不能为空');
		return false;	
	}
	<?php if (@!$row) {?>
	if(password==''){
		parent.showAlert('密码不能为空');
		return false;	
	}
	<?php }?>
	if(email==''){
		parent.showAlert('邮箱不能为空');
		return false;	
	}else{
		<?php
		if (@$row) {
			$url=ZSM_WWW_HOST.'admin.php/admin/home/modifyuser/do/update/id/'.$row['uid'];
		}else{
			$url=ZSM_WWW_HOST.'admin.php/admin/home/roleadduser/do/add';
		}
		?>
		var url = '<?php echo $url;?>';
		
		$.getJSON(url,{
			'username':username,
			'password':password,
			'isadmin':isadmin,
			'email':email,
			'tel':tel
			},function(rs){
			if(rs.status==1){
				parent.showAlert(rs.html);
				setTimeout(function(e){
					if(isadmin!=1){
						window.location.href='<?php echo ZSM_WWW_HOST.'admin.php/admin/home/roleset/id/'?>'+rs.id;
					}else{
						window.location.href='<?php echo ZSM_WWW_HOST.'admin.php/admin/home/user';?>';
					}
				},3000);
			}else{
				parent.showAlert(rs.html);
			}
		})
	}
	return false;
}
function checktutype(e){
	if($(e).val()==1){
		$("#plantform_id").hide();
	}else{
		$("#plantform_id").show();
	}
	
}
</script>

<form action="" method="post" onsubmit="return checkForm();">
<table style="width:100%;line-height: 35px;">
	<tr>
		<td align="right" width="30%">用户名： </td>
		<td align="left" width="70%" >
		
		<?php if (@$row){?>
		<input type="text" style="width:200px;" name="username" id="username" value="<?php echo $row['username'];?>" <?php if ($user['isadmin']>2){?>readonly="readonly"<?php }?> >
		<?php }else{?>
		<input type="text" style="width:200px;" name="username" id="username" value=" ">
		<?php }?>
		</td>
		
	</tr>	
	
	<tr>
		<td align="right" width="30%">密码： </td>
		<td align="left" width="70%" >
		
		<input type="password" style="width:200px;" name="password" id="password" value=""  />(为空表示不修改密码)
		
		</td>
		
	</tr>
	
	<tr>
		<td align="right" width="30%">用户类型： </td>
		<td align="left" width="70%" >
		<select name="isadmin" id="isadmin" onchange="checktutype(this);" >
		<?php if (@$row){?>
		<option value="<?php echo $row['isadmin'];?>"><?php 
		if ($row['isadmin']==1){ echo '超管';}
		if ($row['isadmin']==2){ echo '管理员';}		
		?></option>
		<?php if ($user['isadmin']==1){?>
		<option value="1">超管</option>
		<?php }?>
		<?php }else{?>
		
		<option value="2">管理员</option>
		<?php if ($user['isadmin']==1){?>
		<option value="1">超管</option>
		<?php }?>
		<?php }?>
		</select>
		
		</td>
		
	</tr>
	
	<tr>
		<td align="right" width="30%">电子邮件： </td>
		<td align="left" width="70%" >
		<?php if (@$row){?>
		<input type="text" style="width:200px;" name="email" id="email" value="<?php echo $row['email'];?>">
		<?php }else{?>
		<input type="text" style="width:200px;" name="email" id="email">
		<?php }?>
		</td>
		
	</tr>
	<tr>
		<td align="right" width="30%">电话： </td>
		<td align="left" width="70%" >
		<?php if (@$row){?>
		<input type="text" style="width:200px;" name="tel" id="tel" value="<?php echo $row['tel'];?>">
		<?php }else{?>
		<input type="text" style="width:200px;" name="tel" id="tel">
		<?php }?>
		</td>
		
	</tr>
	<tr>
		<td align="right"  width="30%" ><input type="submit" value="确 认">&nbsp;</td>
		<td align="left"  width="70%" >&nbsp;</td>
		
	</tr>
	
	
</table>
</form>
<?php htmlTemplate('admin_footer_frame.php');?>